/*
menu_destroy();
*/
var menu_id, menu, p;
menu_id = argument[0];
if (is_string(menu_id))
{
    if (ds_grid_value_exists(global.menu_index,0,0,4,ds_grid_height(global.menu_index),menu_id))
    {
        menu = ds_grid_value_y(global.menu_index,0,0,4,ds_grid_height(global.menu_index),menu_id);
        if (ds_grid_height(global.menu_index) > 2)
        {
            global.menu_options = ds_grid_get(global.menu_index, 3, menu - 1);
            global.menu_option_indexes = ds_grid_get(global.menu_index, 4, menu - 1);
            global.menu_id = ds_grid_get(global.menu_index, 0, menu - 1);
        }
        else
        {
            global.menu_options = -1;
            global.menu_option_indexes = -1;
            global.menu_id = -1;
        }
        global.menu_option_selected = -1;
        ds_map_destroy(ds_grid_get(global.menu_index, 3, menu));
        ds_list_destroy((ds_grid_get(global.menu_index, 4, menu)));
        for (n = menu; n < (ds_grid_height(global.menu_index)-menu-1); n += 1)
        {
            for (m = 0; m < ds_grid_width(global.menu_index); m += 1)
            {
                p = ds_grid_get(global.menu_index,m,n+1);
                ds_grid_set(global.menu_index,m,n,p);
            }
        }
        ds_grid_resize(global.menu_index,5,max(ds_grid_height(global.menu_index) - 1, 1));
    }
    else
    {
        show_debug_message("Trying to destroy a non-existent menu. Menu ID: "+string(menu_id));
    }
}
